﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class Default2 : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            NameTextBox.Text = Profile.Name;
            if (Profile.PostalCode > 0)
            {
                PostalTextBox.Text = Profile.PostalCode.ToString();
            }
            if (Profile.ColorPreference.Length > 0)
            {
                ColorsDropDownList.SelectedValue = Profile.ColorPreference.ToString();
            }
        }
    }
    protected void SaveButton_Click(object sender, EventArgs e)
    {
        Profile.Name = NameTextBox.Text;
        Profile.PostalCode = short.Parse(PostalTextBox.Text);
        Profile.ColorPreference = ColorsDropDownList.SelectedValue.ToString();

        Profile.Save();

        Response.Redirect("Default.aspx");
    }
}